Tested:
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 11 Feb 2013 21:50:47 +0000 (21:50 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 11 Feb 2013 21:50:47 +0000 (21:50 +0000)
  Move icon_descr to a reference-counted QString, freeing us from the horror
  of the 'is_dynamic? xfree()' mess and the issues in waypt_dupe.  The code
  is better in some ways, but suffers now while there are still a lot of
  const char*/QString edges, but there's only so much you can do in one commit
  and still keep the tree running.

  Builds Mac and Mingw-cross.  valgrind runs on Ubuntu.  (and caught a few
  errors as I introduced them.)

47 files changed:
gpsbabel/an1.cc
gpsbabel/avltree.cc
gpsbabel/avltree.h
gpsbabel/bcr.cc
gpsbabel/bushnell.cc
gpsbabel/cetus.cc
gpsbabel/compegps.cc
gpsbabel/coto.cc
gpsbabel/csv_util.cc
gpsbabel/defs.h
gpsbabel/delbin.cc
gpsbabel/easygps.cc
gpsbabel/g7towin.cc
gpsbabel/garmin.cc
gpsbabel/garmin_tables.cc
gpsbabel/garmin_tables.h
gpsbabel/garmin_txt.cc
gpsbabel/gbfile.cc
gpsbabel/gbfile.h
gpsbabel/gdb.cc
gpsbabel/geo.cc
gpsbabel/geoniche.cc
gpsbabel/gpilots.cc
gpsbabel/gpsutil.cc
gpsbabel/gpx.cc
gpsbabel/gtm.cc
gpsbabel/gtrnctr.cc
gpsbabel/hiketech.cc
gpsbabel/humminbird.cc
gpsbabel/kml.cc
gpsbabel/lowranceusr.cc
gpsbabel/magellan.h
gpsbabel/magproto.cc
gpsbabel/mapsend.cc
gpsbabel/mapsource.cc
gpsbabel/mmo.cc
gpsbabel/navilink.cc
gpsbabel/osm.cc
gpsbabel/ozi.cc
gpsbabel/pathaway.cc
gpsbabel/psitrex.cc
gpsbabel/raymarine.cc
gpsbabel/tiger.cc
gpsbabel/unicsv.cc
gpsbabel/waypt.cc
gpsbabel/wfff_xml.cc
gpsbabel/xol.cc

index a2263bacb3d0c2894214f31b231034cc72707aa5..64b7adf6d99d611f749eb54f2919e82f73c5a5c5 100644 (file)
@@ -801,14 +801,17 @@ Write_One_AN1_Waypoint(const waypoint* wpt)
   rec->serial = serial++;
 
   if (rec->type == 0x12) {    /* image */
-    if (strstr(wpt->icon_descr, ":\\")) {
-      rec->image_name = xstrdup(wpt->icon_descr);
+    if (wpt->icon_descr.contains(":\\")) {
+      rec->image_name = xstrdup(wpt->icon_descr.toUtf8().data());
       rec->height = -244;
       rec->width = -1;
     }
   }
-  if (!rec->image_name && wpt->icon_descr) {
-    FindIconByName((char*)(void*)wpt->icon_descr, &rec->guid);
+  if (!rec->image_name && !wpt->icon_descr.isNull()) {
+// FIXME: WTH?
+char* t = xstrdup(wpt->icon_descr.toUtf8().data());
+    FindIconByName(t, &rec->guid);
+xfree(t);
   }
 
   Write_AN1_Waypoint(outfile, rec);
index caccace9c37863a026180ecccedddbba0a0334e5..1d7cdb29af9b002cc4a39b5c5f9a5c644a217edc 100644 (file)
@@ -193,6 +193,16 @@ avltree_find(const avltree_t* tree, const char* key, const void** data)
   return (node) ? 1 : 0;
 }
 
+int
+avltree_find(const avltree_t* tree, const QString key, const void** data)
+{
+  const char*t = xstrdup(key.toUtf8().data());
+  int r = avltree_find(tree, key, data);
+  xfree(t);
+  return r;
+  
+}
+
 
 /* Get the first (the MIN-) entry of the tree */
 
index c08c3a8b3c2746738fc17546447cb432b81f6edd..5feea19dd34f960ee8d13d751641093069dd8896 100644 (file)
@@ -79,6 +79,7 @@ avltree_t* avltree_dupe(const avltree_t* tree, const char* module);
 
 /* Find key [key] in tree */
 int avltree_find(const avltree_t* tree, const char* key, const void** data);
+int avltree_find(const avltree_t* tree, const QString key, const void** data);
 
 /* Get the first (the MIN-) entry of the tree */
 const char* avltree_first(const avltree_t* tree, const void** data);
index 5561e379a0551bbae90eb61bafd92a83aa1001f3..60358a5970f8f0a40f8a07ec4ab4a659782931b5 100644 (file)
@@ -154,18 +154,18 @@ bcr_handle_icon_str(const char* str, waypoint* wpt)
 }
 
 static const char*
-get_bcr_icon_from_icon_descr(const char* icon_descr)
+get_bcr_icon_from_icon_descr(QString icon_descr)
 {
   const char* result = BCR_DEF_ICON;
 
-  if (icon_descr) {
+  if (!icon_descr.isNull()) {
     bcr_icon_mapping_t* m;
 
     for (m = bcr_icon_mapping; (m->bcr_name); m++) {
       if (! m->mps_name) {
         continue;
       }
-      if (case_ignore_strcmp(icon_descr, m->mps_name) == 0) {
+      if (icon_descr.compare(m->mps_name, Qt::CaseInsensitive) == 0) {
         result = m->bcr_name;
         break;
       }
index 029cbca5928dd8d3da4ffe6c9d1f4d34ea00201c..d97bb7f8174b141ba12bdd91c4f476a53c01c365 100644 (file)
@@ -126,11 +126,16 @@ icon_mapping_t bushnell_icons[] = {
 };
 
 static unsigned int
-bushnell_get_icon_from_name(const char* name)
+bushnell_get_icon_from_name(QString name)
 {
   icon_mapping_t* t;
+
+  if (name.isNull()) {
+    name = "Waypoint";
+  }
+
   for (t = bushnell_icons; t->icon > 0; t++) {
-    if (0 == case_ignore_strcmp(name, t->icon)) {
+    if (0 == name.compare(t->icon, Qt::CaseInsensitive)) {
       return t->symbol;
     }
   }
@@ -232,8 +237,7 @@ bushnell_write_one(const waypoint* wpt)
   file_out = gbfopen_le(fname, "wb", MYNAME);
   gbfputint32(wpt->latitude  * 10000000, file_out);
   gbfputint32(wpt->longitude * 10000000, file_out);
-  gbfputc(bushnell_get_icon_from_name(wpt->icon_descr ? wpt->icon_descr :
-                                      "Waypoint"), file_out);
+  gbfputc(bushnell_get_icon_from_name(wpt->icon_descr), file_out);
   gbfputc(0x01, file_out);  // Proximity alarm.  1 == "off", 3 == armed.
 
   ident = mkshort(mkshort_handle, wpt->shortname);
index beca8cd306e618e4aa3d789dc3db60ae6495a975..8f29e2fbf0a13a8360276c4bd5c973fd89a313c5 100644 (file)
@@ -565,12 +565,12 @@ cetus_writewpt(const waypoint* wpt)
   xfree(desc_short);
   xfree(desc_long);
 
-  if (appendicon && wpt->icon_descr) {
+  if (appendicon && !wpt->icon_descr.isNull()) {
     int left = DESCSZ - strlen(vdata);
-    int ilen = strlen(wpt->icon_descr);
+    int ilen = strlen(wpt->icon_descr.toUtf8().data());
     if (ilen && left > (ilen+3)) {
       strcat(vdata, " (");
-      strcat(vdata, wpt->icon_descr);
+      strcat(vdata, wpt->icon_descr.toUtf8().data());
       strcat(vdata, ")");
     }
   }
index 66a29e5928eed4eb7a173dafb1a9a5a4c5ad9f5e..093b818daac9cffd4de90d3465a3c682fff87f35 100644 (file)
@@ -243,8 +243,7 @@ parse_wpt_info(const char* buff, waypoint* wpt)             /* "w" */
 #endif
       switch (col) {
       case 0:
-        wpt->icon_descr = xstrdup(c);
-        wpt->wpt_flags.icon_descr_is_dynamic = 1;
+        wpt->icon_descr = c;
         break;
       case 1:
         break;                 /* Text postion */
@@ -502,14 +501,8 @@ write_waypt_cb(const waypoint* wpt)
 
   if ((wpt->icon_descr != NULL) || (wpt->wpt_flags.proximity) || \
       (option_icon != NULL)) {
-    char* icon = option_icon;
-
-    if (wpt->icon_descr != NULL) {
-      icon = (char*) wpt->icon_descr;
-    }
-
     gbfprintf(fout, "w  %s,0,0.0,16777215,255,1,7,,%.1f\n",
-              (icon != NULL) ? icon : "Waypoint",
+              wpt->icon_descr.isNull() ? "Waypoint" : wpt->icon_descr.toUtf8().data(),
               WAYPT_GET(wpt, proximity, 0));
   }
   xfree(name);
index a08d7b74d333a34346d658b334d499e8c4510317..adf5775f5bec57e009b5cf12f9135a455980dc5a 100644 (file)
@@ -271,9 +271,6 @@ coto_wpt_read(void)
     wpt_tmp->shortname = xstrndup(rec->name, sizeof(rec->name));
 
     wpt_tmp->icon_descr = coto_get_icon_descr(pdb_rec->category, app);
-    if (wpt_tmp->icon_descr) {
-      wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
-    }
 
     if ((c = strstr(rec->notes, "\nNotes:\n"))) {      /* remove our contruct */
       wpt_tmp->notes = xstrdup(c + 8);
@@ -382,9 +379,9 @@ coto_wpt_write(const waypoint* wpt)
     xfree(notes);
   }
 
-  if (wpt->icon_descr) {
+  if (!wpt->icon_descr.isNull()) {
     for (i = 1; i < 16; i++)
-      if (!strncmp(wpt->icon_descr, ai->categories[i], 16)) {
+      if (!strncmp(wpt->icon_descr.toUtf8().data(), ai->categories[i], 16)) {
         cat=i;
         break;
       }
@@ -392,11 +389,11 @@ coto_wpt_write(const waypoint* wpt)
       // We have a new one
       if (ai->maxid<15) {
         i = ++ai->maxid;
-        snprintf(ai->categories[i], 16, "%s", wpt->icon_descr);
+        snprintf(ai->categories[i], 16, "%s", wpt->icon_descr.toUtf8().data());
         cat = ai->ids[i] = i;
       } else {
         // We're full!
-        warning(MYNAME ": Categories full. Category '%s' written as %s.\n", wpt->icon_descr, zerocat?zerocat:"Not Assigned");
+        warning(MYNAME ": Categories full. Category '%s' written as %s.\n", wpt->icon_descr.toUtf8().data(), zerocat?zerocat:"Not Assigned");
       }
     }
   }
index 3cefc34cb28c11c19f093b43076b9dd9bb10ad0f..f7c9616a57a64ecd361391cd7e7b6351fa92955b 100644 (file)
@@ -1041,7 +1041,6 @@ xcsv_parse_val(const char* s, waypoint* wpt, const field_map_t* fmp,
     break;
   case XT_ICON_DESCR:
     wpt->icon_descr = csv_stringtrim(s, "", 0);
-    wpt->wpt_flags.icon_descr_is_dynamic = 1;
     break;
 
     /* LATITUDE CONVERSIONS**************************************************/
@@ -1724,8 +1723,8 @@ xcsv_waypt_pr(const waypoint* wpt)
       break;
     case XT_ICON_DESCR:
       writebuff(buff, fmp->printfc,
-                (wpt->icon_descr && *wpt->icon_descr) ?
-                wpt->icon_descr : fmp->val);
+                (!wpt->icon_descr.isNull()) ?
+                wpt->icon_descr.toUtf8().data() : fmp->val);
       break;
 
       /* LATITUDE CONVERSION***********************************************/
index 9447a56b2dac80ee1f7cae98f8f002c62dada6a2..c728828303e19371ac66df42a90b65170dc09710 100644 (file)
@@ -386,7 +386,6 @@ class url_link {
 class wp_flags {
  public:
    wp_flags() :
-    icon_descr_is_dynamic(0),
     shortname_is_synthetic(0),
     cet_converted(0),
     fmt_use(0),
@@ -397,7 +396,6 @@ class wp_flags {
     depth(0),
     is_split(0),
     new_trkseg(0) {} 
-  unsigned int icon_descr_is_dynamic:1;
   unsigned int shortname_is_synthetic:1;
   unsigned int cet_converted:1;                /* strings are converted to UTF8; interesting only for input */
   unsigned int fmt_use:1;                      /* lightweight "extra data" */
@@ -465,7 +463,6 @@ public:
   url_next(NULL), 
   url(NULL), 
   url_link_text(NULL), 
-  icon_descr(NULL), 
 #if NEWTIME
 //  creation_time(QDateTime::fromTime_t(0)),
 #else
@@ -546,7 +543,7 @@ public:
   char* url_link_text;
 
   wp_flags wpt_flags;
-  const char* icon_descr;
+  QString icon_descr;
 #if NEWTIME
   gpsbabel::DateTime creation_time;
 #else
index 1a24d961f627326b0fdf24de4230c47af100bb05..41d2b9355b2aa9330a12b2695fef1e7ece62709b 100644 (file)
@@ -1006,9 +1006,9 @@ decode_waypoint(const void* data)
     wp->altitude = f;
   }
   wp->icon_descr = waypoint_symbol(p->symbol);
-  if (wp->icon_descr) {
-    wp->icon_descr = xstrdup(wp->icon_descr);
-  }
+//  if (!wp->icon_descr.isNull()) {
+//    wp->icon_descr = wp->icon_descr;
+//  }
   if (p->name_size && p->name[0]) {
     wp->description = xstrdup(p->name);
   }
@@ -1186,7 +1186,7 @@ get_gc_notes(const waypoint* wp, int* symbol, char** notes, unsigned* notes_size
   case gt_ape:
     break;
   }
-  if (0 == strcmp(wp->icon_descr, "Geocache Found")) {
+  if (0 == (wp->icon_descr.compare("Geocache Found"))) {
     gc_sym = 124;
   }
   if (wp->description) {
@@ -1201,8 +1201,8 @@ get_gc_notes(const waypoint* wp, int* symbol, char** notes, unsigned* notes_size
   if (gc_sym && opt_gcsym && atoi(opt_gcsym)) {
     gbfprintf(fd, "%s\n", waypoint_symbol(gc_sym));
     *symbol = gc_sym;
-  } else if (wp->icon_descr) {
-    gbfprintf(fd, "%s\n", wp->icon_descr);
+  } else if (!wp->icon_descr.isNull()) {
+    gbfprintf(fd, "%s\n", wp->icon_descr.toUtf8().data());
   }
   switch (wp->gc_data->container) {
   case gc_micro:
@@ -1423,8 +1423,8 @@ write_waypoint(const waypoint* wp)
   le_write_float(p->elevation, elev);
   if (symbol < 0) {
     symbol = 0;
-    if (wp->icon_descr) {
-      symbol = waypoint_symbol_index(wp->icon_descr);
+    if (!wp->icon_descr.isNull()) {
+      symbol = waypoint_symbol_index(wp->icon_descr.toUtf8().data());
     }
   }
   p->symbol = symbol;
index 11c771cd7bacbb4211af78e22fa25d974b7abf29..f644ccd208795bc18bf4eaba839e517b92b46c7f 100644 (file)
@@ -102,7 +102,6 @@ data_read(void)
         break;
       case 7:
         wpt_tmp->icon_descr = gbfgetpstr(file_in);;
-        wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
         break;
       case 8:  /* NULL Terminated (vs. pascal) descr */
         wpt_tmp->notes = gbfgetcstr(file_in);
@@ -154,7 +153,7 @@ ez_disp(const waypoint* wpt)
     gbfputc(3, file_out);
     gbfputpstr(wpt->description, file_out);
   }
-  if (wpt->icon_descr) {
+  if (!wpt->icon_descr.isNull()) {
     gbfputc(7, file_out);
     gbfputpstr(wpt->icon_descr, file_out);
   }
index 6a31212a541df0f548a0bac38c1fa432a5fbe037..b910d6146712499a2ab99fba1f9ad2e9db3590bd 100644 (file)
@@ -115,7 +115,6 @@ parse_line(char* buff, int index, const char* delimiter, waypoint* wpt)
     case WAYPT__OFS + 2:
       wpt->icon_descr = gt_find_desc_from_icon_number(
                           atoi(cin), PCX, &dyn);
-      wpt->wpt_flags.icon_descr_is_dynamic = dyn;
       break;
 
     case WAYPT__OFS + 4:
@@ -474,7 +473,6 @@ data_read(void)
         cdata++;
         wpt->icon_descr = gt_find_desc_from_icon_number(
                             atoi(cdata), PCX, &dyn);
-        wpt->wpt_flags.icon_descr_is_dynamic = dyn;
       }
       waypt_add(wpt);
       break;
index 1f0d2243cf7abaad9ec0de5dbabeefad563015d4..51cf03c34ff04370856a9869d362965a89f06624 100644 (file)
@@ -97,7 +97,7 @@ arglist_t garmin_args[] = {
 };
 
 static const char* d103_symbol_from_icon_number(unsigned int n);
-static int d103_icon_number_from_symbol(const char* s);
+static int d103_icon_number_from_symbol(QString s);
 
 
 static void
@@ -369,7 +369,6 @@ waypt_read(void)
       int dyn = 0;
       wpt_tmp->icon_descr = gt_find_desc_from_icon_number(
                               way[i]->smbl, PCX, &dyn);
-      wpt_tmp->wpt_flags.icon_descr_is_dynamic = dyn;
     }
     /*
      * If a unit doesn't store altitude info (i.e. a D103)
@@ -1273,16 +1272,16 @@ d103_symbol_from_icon_number(unsigned int n)
 }
 
 static int
-d103_icon_number_from_symbol(const char* s)
+d103_icon_number_from_symbol(QString s)
 {
   unsigned int i;
 
-  if (NULL == s) {
+  if (s.isNull()) {
     return 0;
   }
 
   for (i = 0; i < sizeof(d103_icons) / sizeof(d103_icons[0]); i++) {
-    if (0 == case_ignore_strcmp(s, d103_icons[i])) {
+    if (0 == (s.compare(d103_icons[i]), Qt::CaseInsensitive)) {
       return i;
     }
   }
index 49ceea926b17fe09f0ccb8dae9a098958abcab04..2af5b706304775b7203e2ade3e3bc7f3b9e20c4e 100644 (file)
@@ -756,13 +756,13 @@ gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, in
     case MAPSOURCE:
     case GDB:
       if (icon == i->mpssymnum) {
-        return (char*)i->icon;
+        return i->icon;
       }
       break;
     case PCX:
     case GARMIN_SERIAL:
       if (icon == i->pcxsymnum) {
-        return (char*)i->icon;
+        return i->icon;
       }
       break;
     default:
@@ -772,14 +772,14 @@ gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, in
   return DEFAULT_ICON_DESCR;
 }
 
-int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_format)
+int gt_find_icon_number_from_desc(const QString desc, garmin_formats_e garmin_format)
 {
   static int find_flag = 0;
   icon_mapping_t* i;
   int def_icon = DEFAULT_ICON_VALUE;
   int n;
 
-  if (!desc) {
+  if (desc.isNull()) {
     return def_icon;
   }
 
@@ -787,12 +787,12 @@ int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_form
    * If we were given a numeric icon number as a description
    * (i.e. 8255), just return that.
    */
-  n = atoi(desc);
+  n = desc.toInt();
   if (n)  {
     return n;
   }
 
-  if (0 == case_ignore_strncmp(desc, "Custom ", 7)) {
+  if (desc.startsWith("Custom ", Qt::CaseInsensitive)) {
     int base = 0;
     if (garmin_format == GDB) {
       base = 500;
@@ -801,13 +801,13 @@ int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_form
       base = 7680;
     }
     if (base) {
-      n = atoi(&desc[7]);
+      n = desc.mid(7).toInt();
       return n + base;
     }
   }
 
   for (i = garmin_smart_icon_table; global_opts.smart_icons && i->icon; i++) {
-    if (case_ignore_strcmp(desc,i->icon) == 0) {
+    if (desc.compare(i->icon, Qt::CaseInsensitive) == 0) {
       switch (garmin_format) {
       case MAPSOURCE:
       case GDB:
@@ -821,7 +821,7 @@ int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_form
     }
   }
   for (i = garmin_icon_table; i->icon; i++) {
-    if (case_ignore_strcmp(desc,i->icon) == 0) {
+    if (desc.compare(i->icon, Qt::CaseInsensitive) == 0) {
       switch (garmin_format) {
       case MAPSOURCE:
       case GDB:
@@ -845,19 +845,17 @@ int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_form
     const char* prefixes[] = {
       "White ", "Red ", "Green ", "Blue ", "Black ", NULL
     };
-
+    // Rewrite "Green Square" to "Square, Green".
     for (prefix = prefixes; *prefix != NULL; prefix++) {
-      int len = strlen(*prefix);
-
-      if (case_ignore_strncmp(desc, *prefix, len) == 0) {
-        char buff[64];
-        int result;
-
-        snprintf(buff, sizeof(buff), "%s, %s", &desc[len], *prefix);
-        rtrim(buff);
+      if (desc.startsWith(*prefix, Qt::CaseInsensitive)) {
+        QString buff = desc;
+        buff.replace(*prefix, "");
+        buff.append(", ");
+        buff.append(*prefix);
+        buff = buff.trimmed();
 
         find_flag = 1;
-        result = gt_find_icon_number_from_desc(buff, garmin_format);
+        int result = gt_find_icon_number_from_desc(buff, garmin_format);
         find_flag = 0;
 
         return result;
@@ -1039,7 +1037,7 @@ gt_lookup_datum_index(const char* datum_str, const char* module)
 }
 
 gbuint32
-gt_color_value(const int garmin_index)
+gt_color_value(const unsigned int garmin_index)
 {
   if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT)) {
     return gt_colors[garmin_index].rgb;
@@ -1088,7 +1086,7 @@ gt_color_index_by_rgb(const int rgb)
 }
 
 const char*
-gt_color_name(const int garmin_index)
+gt_color_name(const unsigned int garmin_index)
 {
   if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT)) {
     return gt_colors[garmin_index].name;
index ba8a86efd15975c9b5b61d0375e9c929dc682d56..9e06474d035beec10e600e58532e7beb46d73452 100644 (file)
@@ -37,7 +37,7 @@ typedef struct icon_mapping {
 typedef enum {MAPSOURCE, PCX, GARMIN_SERIAL, GDB} garmin_formats_e;
 
 const char* gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic);
-int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_format);
+int gt_find_icon_number_from_desc(const QString desc, garmin_formats_e garmin_format);
 
 extern icon_mapping_t garmin_icon_table[];
 
@@ -95,10 +95,10 @@ grid_type gt_lookup_grid_type(const char* grid_name, const char* module);
 const char* gt_get_mps_grid_longname(const grid_type grid, const char* module);
 int gt_lookup_datum_index(const char* datum_str, const char* module);
 const char* gt_get_mps_datum_name(const int datum_index);
-gbuint32 gt_color_value(const int garmin_index);
+gbuint32 gt_color_value(const unsigned int garmin_index);
 gbuint32 gt_color_value_by_name(const char* name);
 int gt_color_index_by_name(const char* name);
 int gt_color_index_by_rgb(const int rgb);
-const char* gt_color_name(const int garmin_index);
+const char* gt_color_name(const unsigned int garmin_index);
 
 #endif
index 12bcd60cbf20f942f0e662118f18b33d1d535641..8c14153515d33ee0b04d96353285273a5d75d1bd 100644 (file)
@@ -524,7 +524,7 @@ print_string(const char* fmt, const char* string)
 }
 
 static void
-print_string(const char* fmt, const QString string)
+print_string(const char* fmt, QString string)
 {
   print_string(fmt, string.toUtf8().data());
 }
@@ -1174,7 +1174,6 @@ parse_waypoint(void)
       i = gt_find_icon_number_from_desc(str, GDB);
       GMSD_SET(icon, i);
       wpt->icon_descr = gt_find_desc_from_icon_number(i, GDB, &dynamic);
-      wpt->wpt_flags.icon_descr_is_dynamic = dynamic;
       break;
     case 12:
       GMSD_SETSTR(facility, str);
index e85d5622e7e3ee826c3d290ee7fca40ca9114292..a021320b5b4aebe7e8cd44b3d9e2d46fa89a9b62 100644 (file)
@@ -1253,6 +1253,15 @@ gbfputpstr(const char* s, gbfile* file)
   return (len + 1);
 }
 
+int
+gbfputpstr(const QString s, gbfile* file)
+{
+  const char *t = s.toUtf8().data();
+  int r = gbfputpstr(t, file);
+  xfree(t);
+  return r;
+}
+
 /* Much more higher level functions */
 
 gbsize_t
index 7b9a05b9c75bf21d25d923d620d6dd2fb7d31839..0aa9ef72fb9714ddf35100f3c5632272feb45d5d 100644 (file)
@@ -132,6 +132,7 @@ int gbfputflt(const float f, gbfile* file); // write a float value
 int gbfputcstr(const char* s, gbfile* file);   // write string including '\0'
 int gbfputcstr(const QString s, gbfile* file); // write string including '\0'
 int gbfputpstr(const char* s, gbfile* file);   // write as pascal string
+int gbfputpstr(const QString s, gbfile* file); // write as pascal string
 
 gbsize_t gbfcopyfrom(gbfile* file, gbfile* src, gbsize_t count);
 
index a6de7878ae6464a2d6c0fc469b58f0d6e5f6f842..6a726651ecab9e226c0a35c40d4ce4a09ba6a6ce 100644 (file)
@@ -699,7 +699,6 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out)
   }
 
   res->icon_descr = gt_find_desc_from_icon_number(icon, GDB, &dynamic);
-  res->wpt_flags.icon_descr_is_dynamic = dynamic;
 
 #if GDB_DEBUG
   DBG(GDB_DBG_WPTe, icon != GDB_DEF_ICON)
@@ -1673,10 +1672,10 @@ write_waypoint_cb(const waypoint* refpt)
 
     icon = GMSD_GET(icon, -1);
     if (icon < 0) {
-      if (wpt->icon_descr) {
-        icon = gt_find_icon_number_from_desc(wpt->icon_descr, GDB);
-      } else {
+      if (wpt->icon_descr.isNull()) {
         icon = GDB_DEF_ICON;
+      } else {
+        icon = gt_find_icon_number_from_desc(wpt->icon_descr, GDB);
       }
     }
 
index 0d21ea059ec41800b3e611f2e014f8f7c261f1e1..09428d12e8cd313471e313d44cb762156b5e72fe 100644 (file)
@@ -140,8 +140,7 @@ void wpt_link(const char* args, const char** attrv)
 
 void wpt_type(const char* args, const char** unused)
 {
-  wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
-  wpt_tmp->icon_descr = xstrdup(args);
+  wpt_tmp->icon_descr = args;
 }
 
 void wpt_coord(const char* args, const char** attrv)
index 1e6246d8e8be8359327f4f7bb8b127bef8fda679..88e347d2d4fe73ba304a336bc9c93b6bd667c085 100644 (file)
@@ -388,7 +388,6 @@ geoniche_read_asc(void)
     wpt->longitude = lon;
     wpt->altitude = alt;
     wpt->icon_descr = category;
-    wpt->wpt_flags.icon_descr_is_dynamic = 1;
 
     if (gid[0]) {
       wpt->shortname = xstrdup(gid);
@@ -458,7 +457,7 @@ static const char* geoniche_icon_map[] =                    /* MPS */
   /* 52 */ "Mystery or puzzle Cache",
 };
 
-static const char*
+static const QString
 geoniche_icon_to_descr(const int no)
 {
   const char* result = NULL;
@@ -547,10 +546,6 @@ geoniche_read_bin(void)
     GPS_Math_DegMin_To_Deg(londeg, lon, &waypt->longitude);
 
     waypt->icon_descr = geoniche_icon_to_descr(icon_nr);
-    if (waypt->icon_descr != NULL) {
-      waypt->wpt_flags.icon_descr_is_dynamic = 1;
-    }
-
     waypt_add(waypt);
   }
 }
@@ -616,31 +611,31 @@ enscape(char* s)
 static int
 wpt2icon(const waypoint* wpt)
 {
-  const char*  desc = wpt->icon_descr;
+  QString desc = wpt->icon_descr;
 
-  if (!desc) {
+  if (desc.isNull()) {
     return 0;
-  } else if (strstr(desc, "reg")) {
+  } else if (desc.contains("reg")) {
     return 43;
-  } else if (strstr(desc, "trad")) {
+  } else if (desc.contains("trad")) {
     return 43;
-  } else if (strstr(desc, "multi")) {
+  } else if (desc.contains("multi")) {
     return 44;
-  } else if (strstr(desc, "offset")) {
+  } else if (desc.contains("offset")) {
     return 44;
-  } else if (strstr(desc, "virt")) {
+  } else if (desc.contains("virt")) {
     return 45;
-  } else if (strstr(desc, "loca")) {
+  } else if (desc.contains("loca")) {
     return 45;
-  } else if (strstr(desc, "event")) {
+  } else if (desc.contains("event")) {
     return 46;
-  } else if (strstr(desc, "lett")) {
+  } else if (desc.contains("lett")) {
     return 47;
-  } else if (strstr(desc, "hyb")) {
+  } else if (desc.contains("hyb")) {
     return 47;
-  } else if (strstr(desc, "unk")) {
+  } else if (desc.contains("unk")) {
     return 48;
-  } else if (strstr(desc, "cam")) {
+  } else if (desc.contains("cam")) {
     return 49;
   }
 
index 55e04a189fa259294061712c47aa6a8bacc7c010..9abf748fbf0a0295f718abdce51d57a0af61cf99 100644 (file)
@@ -261,7 +261,6 @@ data_read(void)
       WAYPT_SET(wpt_tmp, depth, fi.f);
       fi.i = le_read32(&rec->wpt.d108.dist);
       WAYPT_SET(wpt_tmp, proximity, fi.f);
-      wpt_tmp->wpt_flags.icon_descr_is_dynamic = 0;
       wpt_tmp->icon_descr = gt_find_desc_from_icon_number((rec->wpt.d108.smbl[1] << 8) + rec->wpt.d108.smbl[0], PCX, NULL);
       waypt_add(wpt_tmp);
       break;
index 0fae24e9bf68fa72349bae23038d84fc0ac56ba2..283d970dcc7746c37be4cdaab547a610207a4cf4 100644 (file)
@@ -135,7 +135,7 @@ static void
 gpsutil_disp(const waypoint* wpt)
 {
   double lon,lat;
-  const char* icon_token;
+  QString icon_token;
   char* tdesc = xstrdup(wpt->description);
 
   icon_token = mag_find_token_from_descr(wpt->icon_descr);
@@ -155,7 +155,7 @@ gpsutil_disp(const waypoint* wpt)
              (wpt->altitude < 0.0)) ? 0 : wpt->altitude,
             'm',
             wpt->description ? tdesc : "",
-            icon_token);
+            icon_token.toUtf8().data());
 
   xfree(tdesc);
 }
index 735d8bf08b8d16d1ae8a39259c325d7cc8b5d73d..3131a498b84e2e88272557d4b54a365af44d6b65 100644 (file)
@@ -1133,8 +1133,7 @@ gpx_end(void* data, const XML_Char* xml_el)
   case tt_wpt_sym:
   case tt_rte_rtept_sym:
   case tt_trk_trkseg_trkpt_sym:
-    wpt_tmp->icon_descr = xstrdup(cdatastrp);
-    wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+    wpt_tmp->icon_descr = cdatastrp;
     break;
   case tt_wpt_time:
   case tt_trk_trkseg_trkpt_time:
index 8a4db62721dcd42aa722cb434a34ce189d2cd3a8..6b500eeeff37e68ad5acf9b467b3f1717deb1351 100644 (file)
@@ -712,14 +712,12 @@ gtm_read(void)
   }
 }
 
-int icon_from_descr(const char* descr)
+int icon_from_descr(QString descr)
 {
-  if (descr) {
-    int i;
-    for (i = 0; icon_descr[i]; i++)
-      if (strcmp(icon_descr[i], descr) == 0) {
-        return i;
-      }
+  for (int i = 0; icon_descr[i]; i++) {
+    if (descr.compare(icon_descr[i]) == 0) {
+      return i;
+    }
   }
   return 48;
 }
index 4da40f2ffc44534664ceec1070f08472483323be..455040337943a8de99c1df6b90422f8999afc807 100644 (file)
@@ -615,8 +615,7 @@ gtc_wpt_long(const char* args, const char** unused)
 void
 gtc_wpt_icon(const char* args, const char** unused)
 {
-  wpt_tmp->icon_descr = xstrdup(args);
-  wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+  wpt_tmp->icon_descr = args;
 }
 
 void
index cdde9a5200189b8bdc838c9c29d1e9a7c1056a44..bab21cdc8c8b3dc67aadd00a015bc3509b15de7b 100644 (file)
@@ -184,8 +184,7 @@ void        ht_ident(const char* args, const char** unused)
 static
 void   ht_sym(const char* args, const char** unused)
 {
-  wpt_tmp->icon_descr = xstrdup(args);
-  wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+  wpt_tmp->icon_descr = args;
 }
 
 static
index 4eaa7f85e4f0bc4d08e982214e572dcebf18d6c0..464b463066a0e62521129bb13123bba10897b1cd 100644 (file)
@@ -655,9 +655,9 @@ humminbird_write_waypoint(const waypoint* wpt)
   hum.icon   = 255;
 
   // Icon....
-  if (wpt->icon_descr) {
+  if (!wpt->icon_descr.isNull()) {
     for (i = 0; i < num_icons; i++) {
-      if (!case_ignore_strcmp(wpt->icon_descr, humminbird_icons[i])) {
+      if (!wpt->icon_descr.compare(humminbird_icons[i], Qt::CaseInsensitive)) {
         hum.icon = i;
         break;
       }
@@ -668,7 +668,7 @@ humminbird_write_waypoint(const waypoint* wpt)
         char* match;
         int j;
         xasprintf(&match, "*%s*", humminbird_icons[i]);
-        j = case_ignore_str_match(wpt->icon_descr, match);
+        j = wpt->icon_descr.compare(match, Qt::CaseInsensitive);
         xfree(match);
         if (j != 0) {
           hum.icon = i;
index fb797453e3df705075636e0a513e972b867f43b4..72313555ef6830a0a0aee5c85a007fb47e1a5697 100644 (file)
@@ -344,8 +344,7 @@ void wpt_coord(const char* args, const char** attrv)
 void wpt_icon(const char* args, const char** unused)
 {
   if (wpt_tmp)  {
-    wpt_tmp->icon_descr = xstrdup(args);
-    wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+    wpt_tmp->icon_descr = args;
   }
 }
 
@@ -1506,7 +1505,7 @@ static void kml_geocache_pr(const waypoint* waypointp)
 
 static void kml_waypt_pr(const waypoint* waypointp)
 {
-  const char* icon;
+  QString icon;
 
 #if 0 // Experimental
   if (realtime_positioning) {
@@ -1553,11 +1552,11 @@ static void kml_waypt_pr(const waypoint* waypointp)
 
   // Icon - but only if it looks like a URL.
   icon = opt_deficon ? opt_deficon : waypointp->icon_descr;
-  if (icon && strstr(icon, "://")) {
+  if (icon.contains("://")) {
     kml_write_xml(1, "<Style>\n");
     kml_write_xml(1, "<IconStyle>\n");
     kml_write_xml(1, "<Icon>\n");
-    kml_write_xml(0, "<href>%s</href>\n", icon);
+    kml_write_xml(0, "<href>%s</href>\n", icon.toUtf8().data());
     kml_write_xml(-1, "</Icon>\n");
     kml_write_xml(-1, "</IconStyle>\n");
     kml_write_xml(-1, "</Style>\n");
index 9df1c3afba4d45d65c466a6bd98bba4046f4f593..c2e835cb00c11d1d81b0c1f4653aa05006de27bf 100644 (file)
@@ -268,12 +268,12 @@ lowranceusr_find_desc_from_icon_number(const int icon)
 }
 
 int
-lowranceusr_find_icon_number_from_desc(const char* desc)
+lowranceusr_find_icon_number_from_desc(QString desc)
 {
   const lowranceusr_icon_mapping_t* i;
   int n;
 
-  if (!desc) {
+  if (desc.isNull()) {
     return DEF_ICON;
   }
 
@@ -281,14 +281,14 @@ lowranceusr_find_icon_number_from_desc(const char* desc)
    * If we were given a numeric icon number as a description
    * (i.e. 8255), just return that.
    */
-  n = atoi(desc);
+  n = desc.toInt();
   if (n)  {
     return n;
   }
 
 
   for (i = lowranceusr_icon_value_table; i->icon; i++) {
-    if (case_ignore_strcmp(desc,i->icon) == 0) {
+    if (desc.compare(i->icon,Qt::CaseInsensitive) == 0) {
       return i->value;
     }
   }
@@ -422,11 +422,10 @@ lowranceusr_parse_waypt(waypoint* wpt_tmp)
 
   /* Symbol ID */
   wpt_tmp->icon_descr = lowranceusr_find_desc_from_icon_number(gbfgetint32(file_in));
-  if (!wpt_tmp->icon_descr[0]) {
+  if (wpt_tmp->icon_descr.isNull()) {
     char nbuf[10];
     snprintf(nbuf, sizeof(nbuf), "%d", le_read32(buff));
-    wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
-    wpt_tmp->icon_descr = xstrdup(nbuf);
+    wpt_tmp->icon_descr = nbuf;
   }
 
   /* Waypoint Type (USER, TEMPORARY, POINT_OF_INTEREST) */
@@ -769,7 +768,7 @@ lowranceusr_waypt_disp(const waypoint* wpt)
 
   gbfputint32(Time, file_out);
 
-  if (get_cache_icon(wpt) && wpt->icon_descr && (strcmp(wpt->icon_descr, "Geocache Found") != 0)) {
+  if (get_cache_icon(wpt) && wpt->icon_descr.compare("Geocache Found") == 0) {
     SymbolId = lowranceusr_find_icon_number_from_desc(get_cache_icon(wpt));
   } else {
     SymbolId = lowranceusr_find_icon_number_from_desc(wpt->icon_descr);
@@ -815,7 +814,7 @@ lowranceusr_write_icon(const waypoint* wpt)
 {
   int latmm = lat_deg_to_mm(wpt->latitude);
   int lonmm = lon_deg_to_mm(wpt->longitude);
-  int icon = wpt->icon_descr ?
+  int icon = !wpt->icon_descr.isNull() ?
              lowranceusr_find_icon_number_from_desc(wpt->icon_descr) :
              10003;
 
index 582f9c75afd9916b011fd0b6f89d02c63cec5ea5..2363c1ef031ea19c658b83311d9a1ffc57873c9f 100644 (file)
@@ -44,8 +44,8 @@ typedef struct icon_mapping {
   const char* icon;
 } icon_mapping_t;
 
-const char* mag_find_descr_from_token(const char* token);
-const char* mag_find_token_from_descr(const char* icon);
+QString mag_find_descr_from_token(const char* token);
+QString mag_find_token_from_descr(QString icon);
 
 unsigned int mag_checksum(const char* const buf);
 char* m330_cleanse(char* istring);
index d34fabbcef0497adf49fa1e346aed53f5c09dcf1..0b5f55b0df9163d0551997e9652c9ac1d00b43dd 100644 (file)
@@ -1157,7 +1157,7 @@ mag_rteparse(char* rtemsg)
   }
 }
 
-const char*
+QString
 mag_find_descr_from_token(const char* token)
 {
   icon_mapping_t* i = icon_mapping;
@@ -1177,8 +1177,8 @@ mag_find_descr_from_token(const char* token)
   return icon_mapping[0].icon;
 }
 
-const char*
-mag_find_token_from_descr(const char* icon)
+QString
+mag_find_token_from_descr(QString icon)
 {
   icon_mapping_t* i = icon_mapping;
 
@@ -1187,7 +1187,7 @@ mag_find_token_from_descr(const char* icon)
   }
 
   for (i = icon_mapping; i->token; i++) {
-    if (case_ignore_strcmp(icon, i->icon) == 0) {
+     if (icon.compare(i->icon, Qt::CaseInsensitive) == 0) {
       return i->token;
     }
   }
@@ -1346,7 +1346,7 @@ mag_waypt_pr(const waypoint* waypointp)
   int lon_deg, lat_deg;
   char obuf[200];
   char ofmtdesc[200];
-  const char* icon_token=NULL;
+  QString icon_token;
   char* owpt;
   char* odesc;
   char* isrc = NULL;
@@ -1408,7 +1408,7 @@ mag_waypt_pr(const waypoint* waypointp)
           wpt_len,
           owpt,
           odesc,
-          icon_token);
+          icon_token.toUtf8().data());
   mag_writemsg(obuf);
   xfree(owpt);
   xfree(odesc);
@@ -1505,7 +1505,7 @@ mag_route_trl(const route_head* rte)
   char obuff[256];
   char buff1[64], buff2[64];
   char* pbuff, *owpt;
-  const char* icon_token;
+  QString icon_token;
   int i, numlines, thisline;
 
   /* count waypoints for this route */
@@ -1540,7 +1540,7 @@ mag_route_trl(const route_head* rte)
     }
     owpt = mag_cleanse(owpt);
 
-    sprintf(pbuff, "%s,%s", owpt, icon_token);
+    sprintf(pbuff, "%s,%s", owpt, icon_token.toUtf8().data());
 
     xfree(owpt);
 
index 480eda80a23601733b291446be3da953d7d4b9d4..6bfb41fb79b09a717e4c2628f608d1231af28881 100644 (file)
@@ -270,10 +270,9 @@ mapsend_read(void)
 static void
 mapsend_waypt_pr(const waypoint* waypointp)
 {
-  unsigned char c;
+  unsigned int c = 0;
   double falt;
   static int cnt = 0;
-  const char* iconp = NULL;
   const char* sn = global_opts.synthesize_shortnames ?
                    mkshort_from_wpt(mkshort_handle, waypointp) :
                    waypointp->shortname;
@@ -316,23 +315,25 @@ mapsend_waypt_pr(const waypoint* waypointp)
 
   /* #, icon, status */
   gbfputint32(++cnt, mapsend_file_out);
 
-  if (waypointp->icon_descr) {
+  QString iconp;
+  if (!waypointp->icon_descr.isNull()) {
     iconp = mag_find_token_from_descr(waypointp->icon_descr);
-    if (1 == strlen(iconp)) {
-      c = iconp[0] - 'a';
+    if (1 == iconp.size()) {
+      c = iconp[0].toAscii() - 'a';
     } else {
-      c = iconp[1] - 'a' + 26;
+      c = iconp[1].toAscii() - 'a' + 26;
     }
   } else  {
     c = 0;
   }
   if (get_cache_icon(waypointp)) {
     iconp = mag_find_token_from_descr(get_cache_icon(waypointp));
-    if (1 == strlen(iconp)) {
-      c = iconp[0] - 'a';
+    if (1 == iconp.size()) {
+      c = iconp[0].toAscii() - 'a';
     } else {
-      c = iconp[1] - 'a' + 26;
+      c = iconp[1].toAscii() - 'a' + 26;
     }
   }
 
@@ -381,7 +382,7 @@ static void
 mapsend_route_disp(const waypoint* waypointp)
 {
   unsigned char c;
-  const char* iconp;
+  QString iconp;
 
   route_wp_count++;
 
@@ -396,12 +397,12 @@ mapsend_route_disp(const waypoint* waypointp)
   gbfputdbl(waypointp->longitude, mapsend_file_out);
   gbfputdbl(-waypointp->latitude, mapsend_file_out);
 
-  if (waypointp->icon_descr) {
+  if (!waypointp->icon_descr.isNull()) {
     iconp = mag_find_token_from_descr(waypointp->icon_descr);
-    if (1 == strlen(iconp)) {
-      c = iconp[0] - 'a';
+    if (1 == iconp.size()) {
+      c = iconp[0].toAscii() - 'a';
     } else {
-      c = iconp[1] - 'a' + 26;
+      c = iconp[1].toAscii() - 'a' + 26;
     }
   } else  {
     c = 0;
index ecea85cad5f60a3ae239f082c233429dcd0a6cbc..690bf342d7d251975c55f8420d017adb59b788e7 100644 (file)
@@ -592,7 +592,6 @@ mps_waypoint_r(gbfile* mps_file, int mps_ver, waypoint** wpt, unsigned int* mpsc
 
   /* might need to change this to handle version dependent icon handling */
   thisWaypoint->icon_descr = gt_find_desc_from_icon_number(icon, MAPSOURCE, &dynamic);
-  thisWaypoint->wpt_flags.icon_descr_is_dynamic = dynamic;
 
   /* The following Now done elsewhere since it can be useful to read in and
     perhaps not add to the list */
@@ -611,7 +610,7 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt, const int isR
   int reclen;
   int lat, lon;
   int icon;
-  char* src = "";         /* default to empty string */
+  const char* src = "";         /* default to empty string */
   char* ident;
   char* ascii_description;
   char zbuf[25];
@@ -644,8 +643,7 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt, const int isR
 
   /* might need to change this to handle version dependent icon handling */
   icon = gt_find_icon_number_from_desc(wpt->icon_descr, MAPSOURCE);
-
-  if (get_cache_icon(wpt) /* && wpt->icon_descr && (strcmp(wpt->icon_descr, "Geocache Found") != 0)*/) {
+  if (get_cache_icon(wpt)) {
     icon = gt_find_icon_number_from_desc(get_cache_icon(wpt), MAPSOURCE);
   }
 
@@ -1119,7 +1117,7 @@ mps_routehdr_w(gbfile* mps_file, int mps_ver, const route_head* rte)
   char*                rname;
   char         hdr[20];
   char         zbuf[20];
-  char*                src = "";
+  const char*          src = "";
   char*                ident;
 
   waypoint*    testwpt;
@@ -1283,7 +1281,7 @@ mps_routedatapoint_w(gbfile* mps_file, int mps_ver, const waypoint* rtewpt)
   int                  lon;
   char         zbuf[20];
   char         ffbuf[20];
-  char*                src = "";
+  const char*          src = "";
   char*                ident;
   int                  reclen;
 
index b86e5c6400c7bc10e42b4d2884d4a1e0b0da5419..d46ba9ace34fd6bbfb179b7df202fcbeb91eadc7 100644 (file)
@@ -567,9 +567,8 @@ mmo_read_CObjWaypoint(mmo_data_t* data)
 
     snprintf(key, sizeof(key), "%d", i);
     if (avltree_find(icons, key, (const void**)&name)) {
-      wpt->icon_descr = xstrdup(name);
-      wpt->wpt_flags.icon_descr_is_dynamic = 1;
-      DBG((sobj, "icon = \"%s\"\n", wpt->icon_descr));
+      wpt->icon_descr = name;
+      DBG((sobj, "icon = \"%s\"\n", wpt->icon_descr.toUtf8().data()));
     }
 #ifdef MMO_DBG
     else {
@@ -1020,9 +1019,8 @@ mmo_finalize_rtept_cb(const waypoint* wptref)
     wpt->proximity = wpt2->proximity;
     wpt->wpt_flags.proximity = wpt2->wpt_flags.proximity;
 
-    if (wpt2->icon_descr) {
-      wpt->icon_descr = xstrdup(wpt2->icon_descr);
-      wpt->wpt_flags.icon_descr_is_dynamic = 1;
+    if (!wpt2->icon_descr.isNull()) {
+      wpt->icon_descr = wpt2->icon_descr;
     }
   }
 }
@@ -1347,11 +1345,11 @@ mmo_write_wpt_cb(const waypoint* wpt)
     gbfputflt(0, fout);
   }
 
-  if (wpt->icon_descr) {
+  if (!wpt->icon_descr.isNull()) {
     int i = 0;
 
     while (mmo_icon_value_table[i].icon) {
-      if (case_ignore_strcmp(wpt->icon_descr, mmo_icon_value_table[i].icon) == 0) {
+      if (wpt->icon_descr.compare(mmo_icon_value_table[i].icon, Qt::CaseInsensitive) == 0) {
         icon = mmo_icon_value_table[i].value;
         break;
       }
index 9f80ecf722e0ec34f31ca6b4872ebaff64b562dd..d3e175687664380dc4cc2c37f77d252b3c237c0f 100644 (file)
@@ -174,12 +174,12 @@ static void (*write_route_point)(const waypoint* waypt) = NULL;
 static void (*write_route_end)(const route_head* track) = NULL;
 
 static int
-find_icon_from_descr(const char* descr)
+find_icon_from_descr(QString descr)
 {
   unsigned int i;
 
-  for (i = 0; descr && i < sizeof(icon_table) / sizeof(const char*); i++) {
-    if (strcmp(descr, icon_table[i]) == 0) {
+  for (i = 0; i < sizeof(icon_table) / sizeof(const char*); i++) {
+    if (0 == descr.compare(icon_table[i])) {
       return i;
     }
   }
index 0ed51f38462713985731f53af8074f693da9d5cd..345dd01d144eeca34dd9054a4f41fddb70517405 100644 (file)
@@ -461,7 +461,7 @@ osm_feature_ikey(const char* key)
 }
 
 
-static char*
+static QString
 osm_feature_symbol(const int ikey, const char* value)
 {
   char* result;
@@ -565,7 +565,6 @@ osm_node_tag(const char* args, const char** attrv)
     wpt->shortname = xstrdup(str);
   } else if ((ikey = osm_feature_ikey(key)) >= 0) {
     wpt->icon_descr = osm_feature_symbol(ikey, value);
-    wpt->wpt_flags.icon_descr_is_dynamic = 1;
   } else if (strcmp(key, "note") == 0) {
     if (wpt->notes) {
       char* tmp;
@@ -854,7 +853,7 @@ osm_waypt_disp(const waypoint* wpt)
 
     osm_write_tag("name", wpt->shortname);
     osm_write_tag("note", (wpt->notes) ? wpt->notes : wpt->description);
-    if (wpt->icon_descr) {
+    if (!wpt->icon_descr.isNull()) {
       osm_disp_feature(wpt);
     }
 
index 90632a7ceecf15f8db4c122b64ec68e6686108d6..eddda268c595853a88461d90a5454927b8c68a92 100644 (file)
@@ -537,8 +537,7 @@ ozi_parse_waypt(int field, char *str, waypoint * wpt_tmp, ozi_fsdata *fsdata)
        other types, but it at least maintains fidelity for an ozi->ozi
        operation. */
     if (str && isdigit(str[0])) {
-      wpt_tmp->icon_descr = xstrdup(str);
-      wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
+      wpt_tmp->icon_descr = str;
     }
     break;
   case 6:
@@ -921,8 +920,8 @@ ozi_waypt_pr(const waypoint * wpt)
 
   index++;
 
-  if (wpt->icon_descr && isdigit(wpt->icon_descr[0])) {
-    icon = atoi(wpt->icon_descr);
+  if (wpt->icon_descr.toInt()) {
+    icon = wpt->icon_descr.toInt();
   }
 
   gbfprintf(file_out,
index 8ded97995d668793f4644c1640175419ce9d04c9..f982fa18e2968d27dc96e83e7a2569acba54c2d0 100644 (file)
@@ -472,9 +472,8 @@ int ppdb_read_wpt(route_head *head, int isRoute)
         break;
       case 6:          /* icon */
         if (*str != '\0') {
-          wpt_tmp->icon_descr = xstrdup(str);
+          wpt_tmp->icon_descr = str;
         }
-        wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
         break;
       case 7:          /* notes */
         if (*str != '\0') {
@@ -711,7 +710,7 @@ static void ppdb_write_wpt(const waypoint *wpt)
   buff = ppdb_strcat(buff, ",", NULL, &len);
   /* 6 icon */
 
-  tmp = str_pool_getcpy(wpt->icon_descr, opt_deficon); /* point icon or deficon from options */
+  tmp = str_pool_getcpy(wpt->icon_descr.toUtf8().data(), opt_deficon); /* point icon or deficon from options */
   buff = ppdb_strcat(buff, tmp, NULL, &len);
   buff = ppdb_strcat(buff, ",", NULL, &len);
   /* 7 description */
index 9a6b64b4d14d8eec6965e71d87a0ce0d4a30e922..3dd5ac2eba6b4769560d863b85c1f2262b30f88f 100644 (file)
@@ -362,7 +362,7 @@ psit_waypoint_w(gbfile *psit_file, const waypoint *wpt)
   gbfprintf(psit_file, " %-6s, ", ident);
   icon = gt_find_icon_number_from_desc(wpt->icon_descr, PCX);
 
-  if (get_cache_icon(wpt) && wpt->icon_descr && (strcmp(wpt->icon_descr, "Geocache Found") != 0)) {
+  if (get_cache_icon(wpt) && wpt->icon_descr.compare("Geocache Found") != 0) {
     icon = gt_find_icon_number_from_desc(get_cache_icon(wpt), PCX);
   }
 
index 4e03610d2915722c2b5d4c29981a385d45c62a6b..403adf5a460c6d65fe9c3035e14ea69fedc0683c 100644 (file)
@@ -140,19 +140,19 @@ static raymarine_symbol_mapping_t raymarine_symbols[] = {
 #define RAYMARINE_STD_SYMBOL 3
 
 static int
-find_symbol_num(const char *descr)
+find_symbol_num(const QString descr)
 {
-  if ((descr != NULL) && (*descr)) {
+  if (!descr.isNull()) {
 
     raymarine_symbol_mapping_t *a;
 
     a = &raymarine_symbols[0];
 
     for (unsigned int i = 0; i < RAYMARINE_SYMBOL_CT; i++, a++) {
-      if (case_ignore_strcmp(descr, a->name) == 0) {
+      if (descr.compare(a->name, Qt::CaseInsensitive) == 0) {
         return i;
       }
-      if (a->mps_name && (case_ignore_strcmp(descr, a->mps_name) == 0)) {
+      if (a->mps_name && (descr.compare(a->mps_name, Qt::CaseInsensitive) == 0)) {
         return i;
       }
     }
index 3560de17a6160b935e9991958d7dacac3079e128..7ceb90d32ad95b4a1aa894b22af4f609827cacdc 100644 (file)
@@ -179,13 +179,13 @@ data_read(void)
 static void
 tiger_disp(const waypoint *wpt)
 {
-  const char *pin;
+  QString pin;
   double lat = wpt->latitude;
   double lon = wpt->longitude;
 
   if (iconismarker) {
-    pin = wpt->icon_descr ? wpt->icon_descr : "";
-  } else if (wpt->icon_descr && strstr(wpt->icon_descr, "-unfound")) {
+    pin = wpt->icon_descr;
+  } else if (wpt->icon_descr.contains("-unfound")) {
     pin = unfoundmarker;
   } else if (wpt->creation_time > current_time() - 3600 * 24 * thresh_days) {
     pin = newmarker;
@@ -208,7 +208,7 @@ tiger_disp(const waypoint *wpt)
     }
   }
 
-  gbfprintf(file_out, "%f,%f:%s", lon, lat, pin);
+  gbfprintf(file_out, "%f,%f:%s", lon, lat, pin.toUtf8().data());
   if (!nolabels) {
     char *temp = NULL;
     char *desc = csv_stringclean(wpt->description, ":");
index 3d5dc16b49fee40853f973bcf112c077bc8b0465..d4d3a1ac7a4b6ab256f880ab5bdc2330e59f7ba8 100644 (file)
@@ -940,8 +940,7 @@ unicsv_parse_one_line(char *ibuf)
       break;
 
     case fld_symbol:
-      wpt->icon_descr = xstrdup(s);
-      wpt->wpt_flags.icon_descr_is_dynamic = 1;
+      wpt->icon_descr = s;
       break;
 
     case fld_iso_time:
@@ -1305,6 +1304,14 @@ unicsv_print_str(const char *str)
   }
 }
 
+static void
+unicsv_print_str(const QString s)
+{
+  char *t = xstrdup(s.toUtf8().data());
+  unicsv_print_str(t);
+  xfree(t);
+}
+
 #ifdef UNICSV_GC_READY
 static void
 unicsv_print_data_time(const time_t atime)
@@ -1345,7 +1352,7 @@ unicsv_waypt_enum_cb(const waypoint *wpt)
   if (wpt->altitude != unknown_alt) {
     gb_setbit(&unicsv_outp_flags, fld_altitude);
   }
-  if (wpt->icon_descr && *wpt->icon_descr) {
+  if (!wpt->icon_descr.isNull()) {
     gb_setbit(&unicsv_outp_flags, fld_symbol);
   }
   if (wpt->description && *wpt->description && (strcmp(shortname, wpt->description) != 0)) {
@@ -1603,7 +1610,7 @@ unicsv_waypt_disp_cb(const waypoint *wpt)
     unicsv_print_str(wpt->notes);
   }
   if FIELD_USED(fld_symbol) {
-    unicsv_print_str((wpt->icon_descr != NULL) ? wpt->icon_descr : "Waypoint");
+    unicsv_print_str(wpt->icon_descr.isNull() ? "Waypoint" : wpt->icon_descr);
   }
   if FIELD_USED(fld_depth) {
     if WAYPT_HAS(wpt, depth) {
index 9393f3f1bfd395c4f6f92bf73e4fe22ba1a727fb..f02d2e9def2675802e6b8588aa20047ef34bad86 100644 (file)
@@ -76,9 +76,8 @@ waypt_dupe(const waypoint *wpt)
                   (url_next->url) ? xstrdup(url_next->url) : NULL,
                   (url_next->url_link_text) ? xstrdup(url_next->url_link_text) : NULL);
   }
-  if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic) {
-    tmp->icon_descr = xstrdup(wpt->icon_descr);
-  }
+
+  tmp->icon_descr = wpt->icon_descr;
 
   if (wpt->gc_data != &empty_gc_data) {
     geocache_data *gc_data = (geocache_data*) xmalloc(sizeof(*gc_data));
@@ -422,9 +421,6 @@ waypt_free(waypoint *wpt)
       xfree(tonuke);
     }
   }
-  if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic) {
-    xfree((char *)(void *)wpt->icon_descr);
-  }
 
   if (wpt->gc_data != &empty_gc_data) {
     geocache_data *gc_data = (geocache_data *)wpt->gc_data;
index 1379f0e6ce5c6b23ac739924d83a32f2e8917300..dca8454b12bc35ba3d940dda2dfc7b556ebc6332 100644 (file)
@@ -241,18 +241,17 @@ void wfff_e(const char *args, const char **unused)
     wpt_tmp->altitude = unknown_alt;
     wpt_tmp->fix = fix_unknown;
 
-    wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
     if (case_ignore_strncmp(ap_wep,"On",2)==0) {
       if (case_ignore_strncmp(ap_type,"AP",2)==0) {
-        wpt_tmp->icon_descr = xstrdup(aicicon); /* Infra Closed */
+        wpt_tmp->icon_descr = aicicon; /* Infra Closed */
       } else {
-        wpt_tmp->icon_descr = xstrdup(ahcicon); /* AdHoc Closed */
+        wpt_tmp->icon_descr = ahcicon; /* AdHoc Closed */
       }
     } else {
       if (case_ignore_strncmp(ap_type,"AP",2)==0) {
-        wpt_tmp->icon_descr = xstrdup(aioicon); /* Infra Open */
+        wpt_tmp->icon_descr = aioicon; /* Infra Open */
       } else {
-        wpt_tmp->icon_descr = xstrdup(ahoicon);        /* AdHoc Open */
+        wpt_tmp->icon_descr = ahoicon; /* AdHoc Open */
       }
     }
 
index 874c803cee693720754d92d32a55732aff189d51..0f258f39a63f09438dbd22cff74cd88b725adf05 100644 (file)
@@ -116,8 +116,7 @@ xol_shape(const char *args, const char **attrv)
       }
     } else if (strcmp(avp[0], "icon") == 0) {
       if (wpt) {
-        wpt->icon_descr = xstrdup(avp[1]);
-        wpt->wpt_flags.icon_descr_is_dynamic = 1;
+        wpt->icon_descr = avp[1];
       }
     }
 
@@ -269,7 +268,7 @@ xol_waypt_disp_cb(const waypoint *wpt)
   gbfprintf(fout, "%*s<shape type=\"waypoint\"", space++*2, "");
   xol_write_string("name", name);
   xol_write_string("comment", wpt->notes);
-  xol_write_string("icon", wpt->icon_descr);
+  xol_write_string("icon", wpt->icon_descr.toUtf8().data());
   if (wpt->creation_time) {
     xol_write_time(wpt);
   }